import request from '@/utils/request'

// 查询优惠券信息列表
export function listCoupon (query) {
  return request({
    url: '/prod-api/activity/coupon/list',
    method: 'get',
    params: query
  })
}

// 查询优惠券信息详细
export function getCoupon (couponUid) {
  return request({
    url: '/prod-api/activity/coupon/' + couponUid,
    method: 'get'
  })
}

// 新增优惠券信息
export function addCoupon (data) {
  return request({
    url: '/prod-api/activity/coupon',
    method: 'post',
    data: data
  })
}

// 修改优惠券信息
export function updateCoupon (data) {
  return request({
    url: '/prod-api/activity/coupon',
    method: 'put',
    data: data
  })
}

// 修改优惠券信息
export function updateStatus (couponUid, couponStatus) {
  const data = {
    couponUid, couponStatus
  }
  return request({
    url: '/prod-api/activity/coupon/updateStatus',
    method: 'put',
    data: data
  })
}

// 删除优惠券信息
export function delCoupon (couponUid) {
  return request({
    url: '/prod-api/activity/coupon/' + couponUid,
    method: 'delete'
  })
}

// 查询优惠券规则信息详细
export function getCouponRule (couponUid) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/' + couponUid,
    method: 'get'
  })
}

// 新增优惠券规则信息
export function addCouponRule (data) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/add',
    method: 'post',
    data: data
  })
}

// 修改优惠券规则信息
export function updateCouponRule (data) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/edit',
    method: 'put',
    data: data
  })
}

// 查询会员等级
export function getMemberLevel () {
  return request({
    url: '/prod-api/customer/level/list',
    method: 'get'
  })
}

// 查询省市区
export function getRegionList () {
  return request({
    url: '/prod-api/common/sys_regin/getRegionS',
    method: 'get'
  })
}
// 新增规则
export function addSendRule (data) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/add',
    method: 'post',
    data
  })
}

// 修改规则
export function editSendRule (data) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/edit',
    method: 'put',
    data
  })
}

// 查看规则
export function viewRuleList (params) {
  return request({
    url: '/prod-api/activity/couponInfoSendRule/list',
    method: 'get',
    params
  })
}


//

export function sendCoupon (data) {
  return request({
    url: '/prod-api/activity/coupon/sendCoupon',
    method: 'post',
    data:data
  })
}
